package edu.lhh.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import edu.lhh.model.teachtype;

public class teachtypedao {
	public void add(teachtype type){
		String sql = "INSERT INTO user (uname,pwd,ming,num)  VALUE ('"+type.getUser()+"' , '"+type.getPwd()+"' , '"+type.getMing()+"' , '"+type.getNum()+"')";
		DbUtils.execute(sql);
	}
	public teachtype  findbyname(String uname) throws SQLException{
		teachtype tp = new teachtype();
		String sql = "SELECT * FROM user WHERE uname = '"+uname+"'";
		ResultSet rs = DbUtils.query(sql);
		if(rs.next()){

			tp.setUser(rs.getString("uname"));
			tp.setPwd(rs.getString("pwd"));
			tp.setMing(rs.getString("ming"));
			tp.setNum(rs.getString("num"));
		}
		
		return tp;
	}
	public teachtype  findbynum(String num) throws SQLException{
		teachtype tp = new teachtype();
		String sql = "SELECT * FROM user WHERE num = '"+num+"'";
		ResultSet rs = DbUtils.query(sql);
		if(rs.next()){

			tp.setUser(rs.getString("uname"));
			tp.setPwd(rs.getString("pwd"));
			tp.setMing(rs.getString("ming"));
			tp.setNum(rs.getString("num"));
		}
		
		return tp;
	}
	public ResultSet findscore(String sql){
		ResultSet rs = null;
		
		
		return rs;
	}
	public void uppwd(String uname,String pwd){
		String sql = "UPDATE user SET pwd = '"+pwd+"' WHERE uname = '"+uname+"'";
		DbUtils.execute(sql);
		
		
		
	}
}
